package com.css.fxfzysx.modules.largeScreen.controller;

import com.css.fxfzysx.base.response.RestResponse;
import com.css.fxfzysx.modules.largeScreen.param.ProbabilisticEarthquakeParam;
import com.css.fxfzysx.modules.largeScreen.service.LargeScreenService;
import com.css.fxfzysx.modules.largeScreen.vo.PeCurveVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;

/**
 * 大屏远程调用
 */
@RestController
@RequestMapping("largeScreen")
@Slf4j
public class LargeScreenController {

    @Autowired
    private LargeScreenService largeScreenService;

    /**
     * 获取破坏状态
     * @return
     */
    @GetMapping("getDestructiveState")
    public RestResponse getDestructiveState(){
        try {
            HashMap<String, Object> map = largeScreenService.getDestructiveState();
            return RestResponse.succeed(map);
        } catch (Exception e) {
            log.error("get getDestructiveState error:{}",e.getMessage(),e);
            return RestResponse.fail("查询失败!");
        }
    }

    /**
     * 概率地震
     */
    @PostMapping("getProbabilisticEarthquake")
    public RestResponse getProbabilisticEarthquake(@RequestBody ProbabilisticEarthquakeParam param){
        try {
            PeCurveVo probabilisticEarthquake = largeScreenService.getProbabilisticEarthquake(param);
            return RestResponse.succeed(probabilisticEarthquake);
        } catch (Exception e) {
            log.error("post getProbabilisticEarthquake error:{}",e.getMessage(),e);
            return RestResponse.fail("查询失败!");
        }
    }

    /**
     * 易损性完备度
     * @return
     */
    @GetMapping("getCompleteness")
    public RestResponse getCompleteness(){
        try {
            largeScreenService.getCompleteness();
            return RestResponse.succeed();
        } catch (Exception e) {
            log.error("get getCompleteness error:{}",e.getMessage(),e);
            return RestResponse.fail("查询失败!");
        }
    }
}
